package cn.china.xfood.config;

import cn.china.xfood.service.WebinfoService;
import interceptor.AdminInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.validation.MessageCodesResolver;
import org.springframework.validation.Validator;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.config.annotation.*;

import java.util.List;


@Configuration
public class Interceptor extends WebMvcConfigurerAdapter {



    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    //注册TestInterceptor拦截器
//        InterceptorRegistration registration = registry.addInterceptor(getAdminInterceptor());
//     //配置路径
//        registration.addPathPatterns("/getProductType");                      //所有路径都被拦截
//        registration.excludePathPatterns(                         //添加不拦截路径
//               // "你的登陆路径",            //登录
//                //"/**/*.html",            //html静态资源
//                //"/**/*.js",              //js静态资源
//               // "/**/*.css",             //css静态资源
//               // "/**/*.woff",
//               // "/**/*.ttf"
////                "/**/html/main/main.html",
////                "/**/html/main/visit.html",
////                "/**/html/login/login.html",
////                "/**/html/foods/foods.html",
////                "/**/html/foods/addProduct.html",
////                "/**/html/car/car.html"
//
////                "/**/main.html",
////                "/**/visit.html",
////                "/**/login.html",
////                "/**/foods.html",
////                "/**/addProduct.html",
////                "/**/car.html"
//        );

        registry.addInterceptor(getAdminInterceptor()).addPathPatterns("/getProductType").excludePathPatterns();

    }

    @Bean
    public AdminInterceptor getAdminInterceptor(){

        return new AdminInterceptor();
    }


}
